﻿using ComicWeb.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ComicWeb.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class proc_detailedController : ControllerBase
    {
        private readonly ShopContext _context;
        //注入依赖
        public proc_detailedController(ShopContext context)
        {
            _context = context;
        }
        /// <summary>
        /// 漫画章节
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async  Task<List<VChapterInfo>> GetVClassifications(int id)
        {
            return await _context.VChapterInfos.Where(m=>m.ComicsId== id).ToListAsync(); 
        }
        // Post: api/VClassifications
        /// <summary>
        /// 详情漫画上部分显示
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult<IEnumerable<proc_detailedClass>>> GetVClassifications(string ComicsID,string UsersID)
        {
            var i =int.Parse( ComicsID);var j = int.Parse(UsersID);
            var data = _context.proc_detailedClass.FromSqlRaw($"exec proc_detailed {i} , {j}").ToList();
            return data;
        }
    }
}
